<template>
  <view class="container">
    <custom-search @search="search"></custom-search>
    <view>
      <custom-museum-list :is-show-first="false" :museum-list="list"></custom-museum-list>
    </view>
  </view>
</template>

<script setup lang="ts">
import {onLoad} from "@dcloudio/uni-app";
import {ref} from "vue";
import type {Museum} from "@/interfaces/museum";
import {PageMuseumReqVO} from "@/interfaces/museum";
import {usePageMuseumsApi} from "@/services/api";

const list = ref<Museum[]>([])
const pageMuseumReq = ref<PageMuseumReqVO>({
  current: 1,
  size: 10
})
const search = (key: string) => {
  uni.$u.route({
    url: '/pages/search/search',
    params: {
      key
    }
  })
}
const init = async () => {
  const {data: res} = await usePageMuseumsApi(pageMuseumReq.value)
  list.value = res.list
}
onLoad((query)=>{
  pageMuseumReq.value.name = query?.key
  init()
})
</script>


<style scoped lang="scss">

</style>
